package com.da.javatest.thread.other;

//使用Account.class实现一把锁锁多个资源
public class Account {
    private int balance;

    // 转账
    public void transfer(Account target, int amt) {
        synchronized (Account.class) {
            if (this.balance > amt) {
                this.balance -= amt;
                target.balance += amt;
            }
        }
    }
}
